@layout("/common/_curd/_container.html"){

<script type="text/javascript">
	var ctx = "${basePath}";
	var grid_selector = "#grid-table";
	var pager_selector = "#grid-pager";

	$(function(){
		initGrid();
	});

	function initGrid(){
		var grid_url = ctx + "/snOrderIn/list";
		var _colnames = ["",
			"供应商",
			"类别",
			"操作员",
			"分公司",
			"创建时间",
			"状态ID",
			"状态",
			"备注",
			"操作"];
		var _colmodel = [{name:"id", index:"id",hidden:true, width:100},
			{name:"sname", index:"sname", width:100},
			{name:"type", index:"type", width:100,formatter:function (value, rows, index) {
				if(value ==1){
					return "外购配件";
				}else if(value == 0){
					return "精品装潢";
				}else {
					return "未选择";
				}
			}},
			{name:"uname", index:"uname", width:100},
			{name:"dname", index:"dname", width:100},
			{name:"addtime", index:"addtime", width:100,formatter:function (value, rows, index) {
				if(value !== ""){
					return value.substring(0,10);
				}
			}},
			{name:"status", index:"status",hidden:true, width:100},
			{name:"staname", index:"staname", width:100},
			{name:"remarks", index:"remarks", width:100},
			{name:"remarks", index:"remarks", width:200,formatter:function (value, rows, index) {
				var status =  index.status;
				var orderId = index.id;
				var shhtml = ""
				shhtml += '<a class="btn  btn-success btn-xs" href="#" role="button" onclick="inStore('+orderId+')">一键入库</a>';
				return shhtml;
			}}
		];


			jQuery(grid_selector).jqGrid({
				url : grid_url,
				shrinkToFit : true,
				colNames : _colnames,
				colModel : _colmodel,
				jsonReader : {id :"id"},
				pager : pager_selector,
				postData : {sort : "id",
					where:"{is_store:0,status:"+5+"}",
					order : "desc"}
			});

	}
</script>


<!-- 配置 grid -->
<div class="row">
	<div class="col-xs-12 tb-grid">
		<!-- 配置 查询 -->
		@ var _col=[
		@		{name:"供应商", index:"sname", type:"text"},
		@		{name:"采购类别", index:"type", type:"text"},
		@		{name:"操作员", index:"uname", type:"text"},
		@		{name:"分公司", index:"dname", type:"text"},
		@		{name:"发布时间(大于)",index:"addtime_dategt", type:"date"},
		@		{name:"发布时间(小于)",index:"addtime_datelt", type:"date"},
		@		{name:"状态", index:"status", type:"text"},
		@		{name:"备注", index:"remarks", type:"text"}
		@];
		@ include("/common/_function/_search.html",{"col":_col}){}
		<!-- 按钮 -->
		<!--<div class="welljq well-sm" id="btns"></div>-->
		<div class="welljq well-sm" id="btnsss">
			<!--<button class="btn btn-xs btn-white " id="snOrderIn_daoru" onclick="_add()">-->
				<!--&nbsp;<li class=" fa fa-floppy-o bigger-120"></li>-->
				<!--&nbsp;一键导入&nbsp;-->
			<!--</button>-->
			<!--&nbsp;-->

			<button class="btn btn-xs btn-white " id="snOrderIn_views" onclick="_view()">
				&nbsp;<li class=" fa fa-eye bigger-120"></li>
				&nbsp;查看订单&nbsp;
			</button>
			&nbsp;
			<button class="btn btn-xs btn-white " id="snOrderIn_adds" onclick="_add()">
				&nbsp;<li class=" fa fa-floppy-o bigger-120"></li>
				&nbsp;手动录入&nbsp;
			</button>
			&nbsp;
			<button class="btn btn-xs btn-white " id="snOrderIn_add2" onclick="_out()">
				&nbsp;<li class=" fa fa-floppy-o bigger-120"></li>
				&nbsp;出库&nbsp;
			</button>
			&nbsp;

			<!--<button class="btn btn-xs btn-white " id="snOrderIn_edits"  onclick="_edit()">&nbsp;<li class=" fa fa-pencil  bigger-120">-->
			<!--</li>&nbsp;修改&nbsp;</button>&nbsp;<button class="btn btn-xs btn-white " id="snOrderIn_view">&nbsp;-->
			<!--<li class=" fa fa-eye bigger-120"></li>-->
			<!--&nbsp;查看&nbsp;</button>&nbsp;-->
			<!--<button class="btn btn-xs btn-white " id="snOrderIn_removes" onclick="_remove()">&nbsp;-->
				<!--<li class=" fa fa-times  bigger-120">-->
				<!--</li>&nbsp;删除&nbsp;-->
			<!--</button>&nbsp;-->

			<!--<button class="btn btn-xs btn-white " id="no_pass" onclick="no_pass()">&nbsp;-->
				<!--<li class="glyphicon glyphicon-time  bigger-120">-->
				<!--</li>&nbsp;待审核&nbsp;-->
			<!--</button>&nbsp;-->

			<!--<button class="btn btn-xs btn-white " id="has_pass"  onclick="has_pass()">&nbsp;-->
				<!--<li class=" glyphicon glyphicon-list-alt  bigger-120">-->
				<!--</li>&nbsp;已审核&nbsp;-->
			<!--</button>&nbsp;-->

			<!--<button class="btn btn-xs btn-white " id="all_apply" onclick="all_apply()">&nbsp;-->
				<!--<li class="glyphicon glyphicon-list  bigger-120">-->
				<!--</li>&nbsp;所有申请&nbsp;-->
			<!--</button>&nbsp;-->
		</div>
		<!-- grid -->
		<table id="grid-table"></table>
		<!-- 分页-->
		<div id="grid-pager"></div>
	</div>
</div>


<script>
	inStore = function (orderId) {
		$.get("/snStore/inStore?orderId="+orderId,null,function (res) {
				layer.msg(res.message)
				$jqGrid.jqGrid("setGridParam", { postData: { sort : "id",where:"{is_store:0,status:"+5+"}",order : "desc" }, page: 1 }).trigger("reloadGrid");
		})
	}

	_add = function () {
		var index = layer.open({
			type: 2,
			title:'新增',
			area: ['100%', '100%'],
			maxmin:true,
			shadeClose: true, //点击遮罩关闭
			content:  '/snStore/addbyhand',
			end:function () {
				var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
				parent.layer.close(index); //再执行关闭
//				$jqGrid.jqGrid("setGridParam", { postData: { sort : "id",where:"{is_store:0,status:"+5+"}",order : "desc" }, page: 1 }).trigger("reloadGrid");
			}
		});

		this.layerIndex = index;
	}

	_view = function () {
		var ids = $("#grid-table").jqGrid("getGridParam", "selarrrow");
		var index = layer.open({
			type: 2,
			title:'查看订单',
			area: ['100%', '100%'],
			maxmin:true,
			shadeClose: true, //点击遮罩关闭
			content:  '/snOrderIn/view/'+ids.toString(),
			end:function () {
				$jqGrid.jqGrid("setGridParam", { postData: { sort : "id",where:"{is_store:0,status:"+5+"}",order : "desc" }, page: 1 }).trigger("reloadGrid");
			}
		});
		this.layerIndex = index;
	}

	_out = function () {
		var index = layer.open({
			type: 2,
			title:'出库',
			area: ['100%', '100%'],
			maxmin:true,
			shadeClose: true, //点击遮罩关闭
			content:  '/snStore/out',
			end:function () {
				var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
				parent.layer.close(index); //再执行关闭
//				$jqGrid.jqGrid("setGridParam", { postData: { sort : "id",where:"{is_store:0,status:"+5+"}",order : "desc" }, page: 1 }).trigger("reloadGrid");
			}
		});

		this.layerIndex = index;
	}
</script>
<!-- 引入所需的js -->
@include("/common/_listscript.html"){}

@}